package com.zgd.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
public class HelloSpringController {

	/*返回的是templates中的内容*/
	@RequestMapping("/hellospring")
	public String say(){
		return "index";
	}
	
	/*两种路径访问都可以*/
	@RequestMapping(value={"hello1","hi"})
	public String hi(){
		return "hi";
	}
	
	/*通过路径得到值*/
	@RequestMapping("say/{id}")
	public String say(@PathVariable String id){
		return "id:"+id;
	}
	
	/*原始的访问方式localhost:8081/boy/param?id=3*/
	@RequestMapping("param")
	public String param(@RequestParam(value="id",required=false,defaultValue="123") String id){
		return "id:"+id;
	}
	
	
}
